home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
MPW_TOOL
/
TOOLS
/
TOOLS_WI
/
FLPATH.TXT
next >
Wrap
Text File
|
1990-05-12
|
2KB
|
92 lines
{ An MPW Pascal Tool Demo - John Jeppson
File Path and Directory Information:
what to save, how to extract it, and
how to reconstruct it.
}
PROGRAM test;
USES
Memtypes, Quickdraw, OSIntf, ToolIntf, PackIntf,
CursorCtl, Signal, PasLibIntf, IntEnv;
VAR
{ Info to save - could be made into a record }
volumeName: Str31;
fileName: Str31;
directoryID: longint;
reply: SFReply; { used by this demo }
FUNCTION reconstructWD: integer;
VAR
pb: WDPBRec;
err: OSErr;
s: string;
BEGIN
s := ':';
Insert(volumeName, s, 1);
{get volume refnum}
pb.ioCompletion := NIL;
pb.ioNamePtr := @s;
pb.ioVRefNum := 0;
pb.ioWDProcID := 0;
pb.ioWDDirID := 0;
err := PBOpenWD(@pb, false);
{get WDRefnum}
pb.ioCompletion := NIL;
pb.ioNamePtr := NIL;
{pb.ioVRefNum from above}
pb.ioWDProcID := 0;
pb.ioWDDirID := directoryID;
err := PBOpenWD(@pb, false);
reconstructWD := pb.ioVRefNum;
END;
PROCEDURE extractFilePath;
VAR
pb: WDPBRec;
err: OSErr;
BEGIN
pb.ioCompletion := NIL;
pb.ioNamePtr := @volumeName;
pb.ioVRefNum := reply.vRefNum;
pb.ioWDIndex := 0;
pb.ioWDProcID := 0;
pb.ioWDVRefNum := 0;
err := PBGetWDInfo(@pb, false);
directoryID := pb.ioWDDirID;
END;
PROCEDURE getReply;
VAR
where: Point;
typelist: SFTypeList;
BEGIN
where.h := 75;
where.v := 75;
SFGetFile(where, '', NIL, - 1,
typelist, NIL, reply);
IF reply.good THEN
fileName := reply.fName
ELSE
IEExit(2);
END;
BEGIN
InitGraf(@thePort);
SetFScaleDisable(true);
getReply;
writeln(fileName, reply.vRefNum);
extractFilePath;
writeln(volumeName, directoryID);
writeln('restored WD = ', reconstructWD);
END.